package com.leantech.android.browser.ui.shortcut

import android.os.Bundle
import com.google.android.material.tabs.TabLayoutMediator
import com.leantech.android.browser.R
import com.leantech.android.browser.databinding.ActivityShortCutBinding
import com.leantech.android.browser.ui.BaseActivity
import com.leantech.android.browser.utils.onThrottleClick

class ShortCutActivity : BaseActivity() {

    private lateinit var binding: ActivityShortCutBinding
    private lateinit var pagerAdapter: ShortCutPagerAdapter

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityShortCutBinding.inflate(layoutInflater)
        setContentView(binding.root)

        initView()
    }

    private fun initView() {
        binding.topBar.setTitle(R.string.title_add_entry)
        binding.topBar.addLeftBackImageButton().onThrottleClick {
            finish()
        }



        pagerAdapter = ShortCutPagerAdapter(this)
        binding.viewPager.adapter = pagerAdapter
        binding.viewPager.offscreenPageLimit = 2

        TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
            when (position) {
                0 -> tab.setText(R.string.tab_link)
                1 -> tab.setText(R.string.tab_favorites)
                2 -> tab.setText(R.string.tab_history)
            }
        }.attach()
    }

}